home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Development Tools & Languages / AppsToGo / DTS.Lib / PPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  2.5 KB  |  101 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:        DTS.Lib
  5. ** File:        PPC.c
  6. ** Written by:  Eric Soldan
  7. **
  8. ** Copyright © 1992 Apple Computer, Inc.
  9. ** All rights reserved.
  10. **
  11. ** This is the only PPC code we have so far for this file.  Who knows if we'll do more...
  12. */
  13.  
  14. /* You may incorporate this sample code into your applications without
  15. ** restriction, though the sample code has been provided "AS IS" and the
  16. ** responsibility for its operation is 100% yours.  However, what you are
  17. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  18. ** after having made changes. If you're going to re-distribute the source,
  19. ** we require that you make it clear in the source that the code was
  20. ** descended from Apple Sample Code, but that you've made changes. */
  21.  
  22.  
  23.  
  24. /*****************************************************************************/
  25.  
  26.  
  27.  
  28. #include "PPC.h"
  29. #include "Utilities.h"
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34. /*****************************************************************************/
  35.  
  36. #ifdef applec
  37. #pragma segment ATGAppleTalk
  38. #endif
  39.  
  40. /*****************************************************************************/
  41. /*****************************************************************************/
  42.  
  43.  
  44.  
  45. OSErr    DoIPCListPorts(short *sindx, short *reqCount, short *actCount,
  46.                        LocationNamePtr  loc,
  47.                        PortInfoArrayPtr retInfo,
  48.                        PPCFilterProcPtr filter)
  49. {
  50.     OSErr                err;
  51.     IPCListPortsPBRec    lpPBRec;
  52.     PPCPortRec            portRec;
  53.     PortInfoRec            info;
  54.     Boolean                keeper;
  55.     char                *cptr;
  56.     short                i;
  57.  
  58.     *actCount = 0;
  59.  
  60.     cptr = (char *)&lpPBRec;
  61.     for (i = 0; i < sizeof(IPCListPortsPBRec); ++i) cptr[i] = 0;
  62.  
  63.     portRec.nameScript = 0;
  64.     pcpy(portRec.name, "\p=");                    /* Match all names. */
  65.  
  66.     portRec.portKindSelector = ppcByString;
  67.     pcpy(portRec.u.portTypeStr, "\p=");            /* Match all names. */
  68.  
  69.     lpPBRec.requestCount = 1;
  70.     lpPBRec.portName     = &portRec;
  71.     lpPBRec.locationName = loc;
  72.     lpPBRec.bufferPtr    = &info;
  73.  
  74.     for (; *actCount < *reqCount;) {
  75.  
  76.         lpPBRec.startIndex = *sindx;
  77.         err = IPCListPortsSync(&lpPBRec);
  78.         if (err) return(err);            /* Call IPCListPorts synchronously. */
  79.  
  80.         ++*sindx;    /* We read it once.  Make sure we don't read it again. */
  81.  
  82.         if (!lpPBRec.actualCount) {        /* If this happens, we hit end of list. */
  83.             *reqCount = 0;                /* This is a flag stating that all are read. */
  84.             return(noErr);
  85.         }
  86.  
  87.         keeper = true;
  88.         if (filter)
  89.             keeper = (*filter)(loc, &info);
  90.         if (keeper) {
  91.             retInfo[*actCount] = info;
  92.             ++*actCount;
  93.         }
  94.     }
  95.  
  96.     return(noErr);
  97. }
  98.  
  99.  
  100.  
  101.